package com.hoyo.domain;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Email;

/**
 * <p>Title:用户基本信息实体类</p>
 * <p>Description:用于接收用户对个人信息的修改数据、和展示个人信息</p>
 * @version 1.0
 * @author 龚文伟
 * @date 2017年05月03日
 */
public class UserInfo implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	private int id;
	
	/**		ID of user		**/
	private int userId;
	
	/**	 	account of user		**/
	@NotNull
	private String nickname;
	
	/**	 	password of user		**/
	@Pattern(regexp = "((?=.*\\d)(?=.*\\D)|(?=.*[a-zA-Z])(?=.*[^a-zA-Z]))^.{8,16}", message="至少包含两种不同的字符，长度8-16")
	@NotNull
	private String password;
	
	/**		email of user		**/
	@Email(message="邮箱格式不正确")
	private String email;
	
	/**		telephone of user		**/
	@Pattern(regexp = "(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}", message="手机号码格式不正确")
	private String phone;
	
	/**		sex of user		**/
	private String sex;
	
	/**		birthday of user		**/
	private Date birthday;
	
	/**		money of user		**/
	private float money;
	
	/**		coin of user		**/
	private int coin;
	
	/**		exp of user		**/
	private int exp;
	
	/**		icon of user		**/
	private String icon;
	
	private String description;
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	private String verifyCode;
	
	public UserInfo() {
	}

	public int getId() {
		return id;
	}

	public void setId(int iD) {
		id = iD;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		if(email == null){
			return ;
		}
		int index = email.lastIndexOf("@");
		StringBuilder builder = new StringBuilder();
		for(int i=3; i<index;i++){
			builder.append("*");
		}
		this.email = email.substring(0, 3)+builder.toString()+phone.substring(index+1);
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String telephone) {
		this.phone = telephone;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public float getMoney() {
		return money;
	}

	public void setMoney(float money) {
		this.money = money;
	}

	public int getCoin() {
		return coin;
	}

	public void setCoin(int coin) {
		this.coin = coin;
	}

	public int getExp() {
		return exp;
	}

	public void setExp(int exp) {
		this.exp = exp;
	}
	
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getVerifyCode() {
		return verifyCode;
	}

	public void setVerifyCode(String verifyCode) {
		this.verifyCode = verifyCode;
	}

	@Override
	public String toString() {
		return "UserInfoValueObject [id=" + id + ", nickname=" + nickname + ", password=" + password + ", email="
				+ email + ", phone=" + phone + ", sex=" + sex + ", birthday=" + birthday + ", money=" + money
				+ ", coin=" + coin + ", exp=" + exp + ", icon=" + icon + ", verifyCode=" + verifyCode + "]";
	}
}
